package com.wuyan.locationdog.adapter

import android.graphics.Color
import android.graphics.Typeface
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.LayoutRes
import com.arcsoft.commonbase.bean.CommoditySpec
import com.arcsoft.commonbase.ext.setUnderLine
import com.arcsoft.commonbase.ext.visibleOrGone
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.wuyan.locationdog.R
import leifu.shapelibrary.ShapeView


class ServiceDetailListAdapter(@LayoutRes layoutResId: Int, data: MutableList<CommoditySpec>?) :
    BaseQuickAdapter<CommoditySpec, BaseViewHolder>(layoutResId, data) {


    override fun convert(holder: BaseViewHolder, item: CommoditySpec) {
        holder.apply {
            getView<TextView>(R.id.num).text = "套餐" + (adapterPosition + 1)

            getView<TextView>(R.id.price).text = item.price
            getView<TextView>(R.id.price2).text = "¥" + item.price
            getView<TextView>(R.id.price2).setUnderLine()
            getView<TextView>(R.id.containNum).text = item.containNum + "天"

            getView<ImageView>(R.id.ivCheck).visibleOrGone(item.isSelect)

            val shapeView = getView<ShapeView>(R.id.shapeView)
            if (item.isSelect) {
                shapeView.setShapeStrokeColor(Color.parseColor("#6E4DF3"))
                    .setShapeSolidColor(Color.parseColor("#0A1259FF"))
                    .setShapeStrokeWidth(2)
                    .setUseShape()
                getView<TextView>(R.id.price).setTypeface(null, Typeface.BOLD)
            } else {
                shapeView.setShapeStrokeColor(Color.parseColor("#D9D9D9"))
                    .setShapeSolidColor(Color.WHITE)
                    .setShapeStrokeWidth(1)
                    .setUseShape()
                getView<TextView>(R.id.price).setTypeface(null, Typeface.NORMAL)

            }

        }
    }
}


